import request from "../service/request";

export function getHttp(url: string, params = {}, headers = {}) {
  return request({
    url,
    method: "get",
    params: params,
    headers: headers,
  });
}

export function postHttp(url: string, data = {}, headers = {}) {
  return request({
    url,
    method: "post",
    data: data,
    headers: {
      ...headers,
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
}

export function postHttpHeaders(url: string, headers = {}) {
  return request({
    url,
    method: "post",
    headers: headers
  });
}

export function postHttpMulti(url: string, data = {}, headers = {}) {
  return request({
    url,
    method: "post",
    data: data,
    headers: {
      ...headers,
      "Content-Type": "multipart/form-data",
    },
  });
}

export function postHttpJSON(url: string, data = {}, headers = {}) {
  return request({
    url,
    method: "post",
    data: data,
    headers: {
      ...headers,
      "Content-Type": "application/json;charset=utf-8",
    },
  });
}

export function postHttpParams(url: string, headers = {}, params = {}) {
  return request({
    url,
    method: "post",
    headers: headers,
    params: params,
  });
}

export function putHttp(url: string, data = {}, headers = {}) {
  return request({
    url,
    method: "put",
    data: data,
    headers: headers,
  });
}

export function putHttpJSON(url: string, data = {}, headers = {}) {
  return request({
    url,
    method: "put",
    data: data,
    headers: {
      ...headers,
      "Content-Type": "application/json;charset=utf-8",
    },
  });
}

export function putHttpParams(url: string, params = {}, headers = {}) {
  return request({
    url,
    method: "put",
    params: params,
    headers: headers
  });
}

export function deleteHttp(url: string, params = {}, headers = {}) {
  return request({
    url,
    method: "delete",
    params: params,
    headers: headers,
  });
}
